package com.gglx.flex.components
{
	import flash.display.BitmapData;

	import mx.core.UIComponent;

	public class GGUIComponent extends UIComponent
	{
		protected var canvasBuffer:BitmapData;

		public function GGUIComponent()
		{
			super();
		}

		public function resetData():void
		{
		}

		override protected function createChildren():void
		{
		}

		override protected function measure():void
		{
			super.measure();

			measuredWidth = measuredMinWidth = getStyle("minWidth");
			measuredHeight = measuredMinHeight = getStyle("minHeight");
		}

		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			if (visible) // chỉ update khi visible!!!
			{
				graphics.clear();

				super.updateDisplayList(unscaledWidth, unscaledHeight);

				drawBackground(unscaledWidth, unscaledHeight);

				layoutContents(unscaledWidth, unscaledHeight);
			}
		}

		/**
		 * MUST BE OVERRIDE<br />
		 * Hàm vẽ background cho item renderer<br />
		 * được gọi bởi hàm <code>updateDisplayList()</code><br />
		 * overrides hàm này để vẽ trạng thái của item khi <code>down, selected, showsCaret & data changed</code><br />
		 */
		protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void
		{
		}

		/**
		 *  MUST BE OVERRIDE<br />
		 *  Positions the children for this component
		 */
		protected function layoutContents(unscaledWidth:Number, unscaledHeight:Number):void
		{
		}
	}
}
